/* eslint-disable */

(function ($) {

  $.fn.board = function (options, arg1, arg2) {

    function init() {
      // 初始化拖拽排序功能
      function initSortable() {
        var Sortable = options.components.Sortable;
  
        // 如果没有注入 SortableJS 依赖，则不启用这个功能
        if (!Sortable) {
          return false;
        }
        $this.addClass('boards-sortable');
        Sortable.create($this[0], {
          handle: '.board-title',
          onUpdate: function () {
            var state;
            var list = [];
            var sortedBoards;
            var sortedStates;
  
            for (state in boards) {
              list.push(boards[state]);
            }
            sortedBoards = list.sort(function (a, b) {
              return a.$board.index() - b.$board.index();
            });
            sortedStates = sortedBoards.map(function (board) {
              return board.state;
            });
            $this.trigger('sorted.boards', { states: sortedStates });
          }
        })
        return true;
      }
    }
  }
  
  })(jQuery);
  